from pydantic import BaseModel


class RootConfig(BaseModel):
    app_select: str
    help_info: str
    apps: dict[str, dict[str, str]]


class Filter_Section_Type(BaseModel):
    # 0x*** 的字符串表示
    start: str
    end: str


class Config_Dev_Settings_Type(BaseModel):
    dev_type: str
    dev_channel: int
    filter_sections: list[Filter_Section_Type] = []
    base_param: dict[str, str] = {}
    canFD: bool = False


class Ecu_UnitTestConfig_Type(BaseModel):
    pos: str
    name: str
    zh_name: str
    srcAddr: str
    dstAddr: str

    # [ ] 当can_can 模式时，可能不需要提供algo和Learmask
    algo: str | None
    Learmask: str | None = "a5a5a5a5a"


class Uds_Can_UnitTestData_Type(BaseModel):
    """
    每个单点测试数据,测试名称,发送数据,接收数据
    """
    name: str
    send: str
    rcevId: str
    rcev: str


class Functest_PosUnit_Data_Type(BaseModel):
    pos: str     # 位置row column 的数字
    name: str
    ecu_pos: str    # ecu_map_dict 中的key
    testDatas: list[Uds_Can_UnitTestData_Type]


class Functest_Template_Uds_Can_Config_Type(BaseModel):
    ecu_map_dict: dict[str, str]
    func_tests: dict[str, Functest_PosUnit_Data_Type]


class TestView_Unit_Type(BaseModel):
    # btn_pos 是按钮的行列位置
    # func_lib 是功能库的名称
    # func_pos 是在功能库中的行列位置
    # name 是按钮的显示名称
    btn_pos: str
    name: str
    func_lib: str
    func_pos: str
